<template>
  <div class="person">
    <h1>姓名： {{ name }}</h1>
    <h1>年龄：{{ age }}</h1>
    <button @click="showPhone">查看手机号</button>
    <button @click="changeName">修改名称</button>
    <button @click="changeAge">修改年龄</button>
  </div>
</template>

<script lang="ts">
export default {
  name: "Person", //组件名称,一般与文件名相同
  data() {
    return {
      name: "李四",
      age: 18,
      phone: "138989843534",
    };
  },
  methods: {
    showPhone() {
      alert(this.phone);
    },
    changeName() {
      this.name = "Li-Si";
    },
    changeAge() {
      this.age += 1;
    },
  },
};
</script>

<style>
.person {
  background-color: skyblue;
  box-shadow: 0 0 10px;
  border-radius: 10px;
  padding: 20px;
}

button {
  margin: 0 5px;
}
</style>
